{:W('Nav',array('name'=>'权限配置'))}
<link href="__PUBLIC__/Css/node.css" rel="stylesheet"/>
<script src="__PUBLIC__/Js/jquery-1.7.2.min.js"></script>
<!-- 订单列表 -->
<form action="setAccess" method="post">
    <input type="hidden" name="id" value="{$id}">
    <div id="wrap">
        <a href="javascript:void 0;" class="add-app" onClick='javascript:history.back(-1);'>返回</a>

        <foreach name="nodeArr" item="v">
            <div class="app">
                <p>
                    <strong>{$v.title}</strong>
                    <input type="checkbox" name="access[]" value="{$v.id}_1" level="1" <if condition="$v['access'] ">checked</if>>
                </p>
                <foreach name="v.child" item="val">
                    <dl>
                        <dt>
                            <strong>{$val.title}</strong>
                            <input type="checkbox" name="access[]" value="{$val.id}_2" level="2" <if condition="$val['access'] ">checked</if>>
                        </dt>
                        <foreach name="val.child" item="value">
                            <dd>
                                <strong>{$value.title}</strong>
                                <input type="checkbox" name="access[]" value="{$value.id}_3" level="3" <if condition="$value['access'] ">checked</if>>
                            </dd>
                        </foreach>
                    </dl>
                </foreach>
            </div>
        </foreach>
    </div>
    <input type="submit" value="保存修改"
           style=" height: 30px;width: 80px;;display: block;margin: 20px auto; cursor: pointer"/>
</form>
<script language="JavaScript">
    function sure($id) {
        var xmlhttp = new XMLHttpRequest();
        var act = "{:U(GROUP_NAME.'/Order/sureOrder')}";
        xmlhttp.open("POST", act, false);
        xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlhttp.send("id=" + $id);
        if (xmlhttp.responseText == true) {
            document.getElementsByName($id)[0].innerText = '已确认';
            document.getElementsByName('sure_' + $id)[0].innerText = ' ';
        } else {
            alert('传输错误，请稍后重试');
        }
    }
</script>

<script type="text/javascript">
    $(function () {
        $('input[level=1]').click(function () {
            var inputs = $(this).parents('.app').find('input');
            $(this).attr('checked') ? inputs.attr('checked', 'checked') :
                    inputs.removeAttr('checked');
        });
        $('input[level=2]').click(function () {
            var inputs = $(this).parents('dl').find('input');
            $(this).attr('checked') ? inputs.attr('checked', 'checked') :
                    inputs.removeAttr('checked');
        })

    })
</script>

</body>
</html>